home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / lsinitramfs < prev    next >
Encoding:
Text File  |  2011-05-16  |  1.1 KB  |  61 lines

  1. #!/bin/sh
  2.  
  3. set -eu
  4.  
  5. usage()
  6. {
  7.     echo "Usage: $(basename $0) <initramfs file>"
  8. }
  9.  
  10. if [ "$#" -eq 0 ] ; then
  11.     usage >&2
  12.     exit 1
  13. fi
  14.  
  15. cpio_args="--extract --quiet --list"
  16.  
  17. OPTIONS=`getopt -o hl --long help,long -n "$0" -- "$@"`
  18. # Check for non-GNU getopt
  19. if [ $? != 0 ] ; then echo "W: non-GNU getopt" >&2 ; exit 1 ; fi
  20.  
  21. eval set -- "$OPTIONS"
  22.  
  23. while true; do
  24.         case "$1" in
  25.         -h|--help)
  26.         usage
  27.         exit 0
  28.     ;;
  29.     -l|--long)
  30.         cpio_args="${cpio_args:+${cpio_args} --verbose}"
  31.         shift
  32.     ;;
  33.     --)
  34.         shift
  35.         break
  36.     ;;
  37.     *)
  38.         echo "Internal error!" >&2
  39.         exit 1
  40.     esac
  41. done
  42.  
  43. for initramfs in "$@" ; do
  44.     if ! [ -r "${initramfs}" ] ; then
  45.         echo "Specified file could not be read." >&2
  46.         exit 1
  47.     else
  48.         echo "${initramfs}"
  49.         if zcat -t "${initramfs}" >/dev/null 2>&1 ; then
  50.             zcat "${initramfs}" | cpio ${cpio_args}
  51.         elif xzcat -t "$initramfs" >/dev/null 2>&1 ; then
  52.             xzcat "$initramfs" | cpio ${cpio_args}
  53.         elif bzip2 -t "$initramfs" >/dev/null 2>&1 ; then
  54.             bzip2 -c -d "$initramfs" | cpio ${cpio_args}
  55.         elif lzop -t "$initramfs" >/dev/null 2>&1 ; then
  56.             lzop -c -d "$initramfs" | cpio ${cpio_args}
  57.         fi
  58.  
  59.     fi
  60. done
  61.